<?php
	App::import("Controller","Sociable.SociableConfig");
	class FacebookConfigController extends SociableConfigController
	{
		var $name = "FacebookConfig";
		public $abstractView = "sociable.sociable_config";
		var $uses = array("Sociable.FacebookConfig");
		function admin_setting()
		{
			parent::admin_setting("Facebook");
		}
		
		function admin_mapFbFields()
		{
			$this->FacebookConfig->init();
			$UserFieldModel = cri("UserField");
			$facebookFields = $UserFieldModel->getFacebookFields();
			$userFields = $UserFieldModel->getFieldsForFacebook();
			if($this->data)
			{
				$fbFields = $this->data['FacebookConfig'];
				foreach(array_keys($userFields) as $userField)
				{
					$fbField = "";
					if(isset($fbFields[$userField]) && $fbFields[$userField])
					{
						$fbField = $fbFields[$userField];
					}
					$data = array();
					$data['FacebookConfig']['facebook_fields'][$userField] = $fbField;
					$this->FacebookConfig->create();
					$this->FacebookConfig->save($data);
				}
				$this->successMsg(__("You setting has been saved."));
			}else
			{
				$this->data['FacebookConfig'] = cr("FacebookConfig.facebook_fields");
			}
			$this->set(compact("facebookFields","userFields"));
		}
	}
?>